package ofc4j.util;

import ofc4j.model.elements.PieChart;
import ofc4j.model.elements.PieChart.Slice;

import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.io.path.PathTrackingWriter;

public class PieChartSliceConverter extends ConverterBase<Slice> {
    @Override
    @SuppressWarnings("unchecked")
    public boolean canConvert(Class c) {
        return PieChart.Slice.class.isAssignableFrom(c);
    }

    @Override
    public void convert(Slice o, PathTrackingWriter writer, MarshallingContext mc) {
        writeNode(writer, "value", o.getValue());
        writeNode(writer, "text", o.getText());
    }
}
